<?php echo $this->render('admin/head.phtml');?>
<div class="align-right"><a href="/admin/add-category">添加分类</a></div>
<div class="align-left">
<form action="?" method="post">
 <!-- 父分类： -->
 <!--    <select name="parent" id="parent_category"> -->
 <!--    <?php echo make_options($this->parents, $this->select_category); ?> -->
 <!--    </select> -->
 <!--    选择二级分类： -->
 <!--    <select name="second_parent" id="sub_category"> -->
 <!--    <?php echo make_options($this->second_parents, $this->select_second_category); ?> -->
 <!--    </select> -->
	<?php $i=0;if (count($this->path) > 0){
	      foreach ($this->path as $category){ ?>
	<div class="left">
	<select class="category" name="cat_id_<?php echo $i;?>" id="category_<?php echo $i;?>" index="<?php echo $i++;?>">
	  <?php print make_options($category['categories'], $category['select']->get('id'));?>
	</select>
	</div>
	<?php }}else{ ?>
	<div class="left">
	<select class="category" name="cat_id_<?php echo $i;?>" id="category_<?php echo $i;?>" index="<?php echo $i++;?>">
      	  <?php print make_options($this->parents);?>
        </select>
	</div>
	<?php }for(;$i<5; ){ ?>
	<div class="left">
	<select class="category" name="cat_id_<?php echo $i;?>" id="category_<?php echo $i;?>" index="<?php echo $i++;?>" style="display: none;">
	</select>
	</div>
	<?php } ?>

	<!-- <?php $i=0;foreach ($this->path as $category){ ?> -->
	<!-- <select class="category" name="cat_id_<?php echo $i;?>" id="category_<?php echo $i;?>" index="<?php echo $i++;?>"> -->
	<!--   <?php print make_options($category['categories'], $category['select']->get('id'));?> -->
	<!-- </select> -->
	<!-- <?php } for(;$i<5; ){ ?> -->
	<!-- <select class="category" name="cat_id_<?php echo $i;?>" id="category_<?php echo $i;?>" index="<?php echo $i++;?>" style="display: none;"> -->
	<!-- </select> -->
	<!-- <?php } ?> -->

    <input type="submit" value="查询"/>
</form>
</div>
<br/>
<table cellspacing="0" cellpadding="0" class="resultTable">
  <tr>
    <th>分类号</th> 
    <th>父分类</th> 
    <th>分类名称</th> 
    <th>操作</th>
  </tr>
  <?php $i=1;if(isset($this->categories) && count($this->categories) > 0){
  foreach ($this->categories as $category){?>
  <tr class="<?php echo ($i++)%2 ? "" : "bg2";?>">
    <td><?php echo $category->get('id');?></td>
    <td><?php echo isset($this->second_parents[$category->get('parent')]) ? $this->second_parents[$category->get('parent')] : (isset($this->parents[$category->get('parent')]) ? $this->parents[$category->get('parent')] : "");?></td>
    <td><?php echo $category->get('name');?></td>
    <td>
      <a href="/admin/edit-category?cat_id=<?php echo $category->get('id');?>">编辑</a>
      <a href="/admin/del-category?cat_id=<?php echo $category->get('id');?>">删除</a>
    </td>
  </tr>
  <?php }} ?>
</table>
<?php echo $this->render('admin/foot.phtml');?>
